/**
 * 对象转url param参数
 * @param {*} obj
 */
export const objToUrlParams = (obj) => {
  let params = '?';
  for (const key in obj) {
    if (obj.hasOwnProperty(key)) {
      const element = obj[key];
      params += `${key}=${element}&`;
    }
  }
  return params.slice(0, params.length - 1);
};

export const treeSelectFormData = (tree, fieldsName) => {
  tree?.map((item) => {
    item.title = item[fieldsName.title];
    item.key = item[fieldsName.value];
    item.value = item[fieldsName.value];
    item.children = item[fieldsName.children];
    item?.children?.length && treeSelectFormData(item.children, fieldsName);
  });
  return tree;
};
